﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace WP7.LockerPlayer.ViewModels
{
    public class ArtistsByName : ObservableCollection<ArtistViewModelGrouping>
    {
        private static readonly string Groups = "#abcdefghijklmnopqrstuvwxyz";
        private Dictionary<int, ArtistViewModel> _aristLookupLookup = new Dictionary<int, ArtistViewModel>();

        public ArtistsByName(ObservableCollection<ArtistViewModel> artistsVM)
        {
            List<ArtistViewModel> artists = new List<ArtistViewModel>();
            artists.AddRange(artistsVM);
            artists.Sort(ArtistViewModel.CompareByName);
            Dictionary<string, ArtistViewModelGrouping> groups = new Dictionary<string, ArtistViewModelGrouping>();

            foreach (char c in Groups)
            {
                ArtistViewModelGrouping group = new ArtistViewModelGrouping(c.ToString());
                this.Add(group);
                groups[c.ToString()] = group;
            }

            foreach (ArtistViewModel person in artists)
            {
                groups[ArtistViewModel.GetFirstNameKey(person)].Add(person);
            }
        }
        public ArtistsByName()
        {
            List<ArtistViewModel> artists = new List<ArtistViewModel>(MainViewModel.Instance.Artists);
            artists.Sort(ArtistViewModel.CompareByName);

            Dictionary<string, ArtistViewModelGrouping> groups = new Dictionary<string, ArtistViewModelGrouping>();

            foreach (char c in Groups)
            {
                ArtistViewModelGrouping group = new ArtistViewModelGrouping(c.ToString());
                this.Add(group);
                groups[c.ToString()] = group;
            }

            foreach (ArtistViewModel person in artists)
            {
                groups[ArtistViewModel.GetFirstNameKey(person)].Add(person);
            }

        }
    }
}
